<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    async function t6() {
    let a = await fn().then((res)=>{return res})
        console.log(a);//undefined
    }
    async function fn(){
        await new Promise((resolve)=>{
            resolve("mango")
        })
    }
    t6();

    /* 每隔3秒输出4次122 */
    function repeat (func, times, wait) {
        return async function(...arg){
            for(let i=0;i<times;i++){
                await new Promise(function(resolve,reject){
                    setTimeout(()=>{
                        func.apply(this,arg)
                        resolve();
                    },wait)
                })
            }
        } 
    };
    const repeatFunc = repeat(console.log, 4, 3000);
    repeatFunc("122");
</script>
</html>